import { ref, reactive, Ref } from "vue-demi"
import { ElFormType } from "../type"
function useState() {
  const formRef = ref<ElFormType>() as Ref<ElFormType>
  const formData = reactive({
    account: "",
    password: "",
    confirmPassword: "",
    name: "",
  })
  const btnLoading = ref(false)
  const formRules = {
    account: [
      { required: true, message: "请输入账号", trigger: "blur" },
      { min: 6, max: 15, message: "账号长度应为6到15个字符", trigger: "blur" },
    ],
    password: [
      { required: true, message: "请输入密码", trigger: "blur" },
      { min: 6, max: 15, message: "密码长度应为6到15个字符", trigger: "blur" },
    ],
    confirmPassword: [
      { required: true, message: "请再次输入密码", trigger: "blur" },
    ],
    name: [
      { required: true, message: "请输入你的用户昵称", trigger: "blur" },
      { min: 2, max: 8, message: "昵称长度应为2到8个字符", trigger: "blur" },
    ],
  }
  return { btnLoading, formRef, formData, formRules }
}
export default useState
